#include <iostream>
#include <utility>
using namespace std;


int  GetMonthday(int year, int month, int day)
{
    static int months[13] = { -1,31,28,31,30,31,30,31,31,30,31,30,31 };
    if (month == 2 && (year % 4 == 0 && year % 100 != 0 || year % 400 == 0))
    {
        return 29;
    }
    return months[month];
}










int main()
{
    int years, days;
    while (cin >> years >> days)
    {
        int year, month, day;
        year = years;
        month = 1;
        day = 1;
        while (days > GetMonthday(year, month, day))
        {
            days -= GetMonthday(year, month, day);
            day = GetMonthday(year, month, day);
            month++;
        }
        if (days > 0)
        {
            day = days;


        }
        if (month < 10 && day < 10)
            printf("%d-0%d-0%d\n", year, month, day);
        else if (month < 10)
            printf("%d-0%d-%d\n", year, month, day);
        else if (day < 10)
            printf("%d-%d-0%d\n", year, month, day);
        else
            printf("%d-%d-%d\n", year, month, day);




    }

}